home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / xcmd / prflds23.sit / PrFlds XCMD 2.3.1 / card_3926.txt < prev    next >
Text File  |  1991-01-03  |  23KB  |  392 lines

  1. -- card: 3926 from stack: in.1
  2. -- bmap block id: 2139
  3. -- flags: 4000
  4. -- background id: 3627
  5. -- name: Title Card
  6.  
  7.  
  8. -- part 2 (button)
  9. -- low flags: 80
  10. -- high flags: 8003
  11. -- rect: left=98 top=198 right=223 bottom=211
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: load fields
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   go to card 2
  23.   put empty into accum
  24.   put the number of bkgnd fields into howMany
  25.   repeat with ii = 1 to howMany
  26.     put quote & the short name of bkgnd field ii & quote into thingg
  27.     put the short ID of bkgnd field ii & "," before thingg
  28.     put thingg into line ii of accum
  29.   end repeat
  30.   go to card 1
  31.   put accum into card field "field info 1"
  32. end mouseUp
  33.  
  34.  
  35.  
  36. -- part 19 (field)
  37. -- low flags: 01
  38. -- high flags: 0000
  39. -- rect: left=242 top=69 right=94 bottom=322
  40. -- title width / last selected line: 0
  41. -- icon id / first selected line: 0 / 0
  42. -- text alignment: 0
  43. -- font id: 2
  44. -- text size: 18
  45. -- style flags: 0
  46. -- line height: 24
  47. -- part name: version
  48. ----- HyperTalk script -----
  49. on mouseUp
  50.   if the optionKey is down then
  51.     put me into thingg
  52.     ask "Version Number:" with thingg
  53.     if it is empty then exit mouseUp
  54.     put it into me
  55.   end if
  56. end mouseUp
  57.  
  58.  
  59. -- part 12 (field)
  60. -- low flags: 80
  61. -- high flags: 4007
  62. -- rect: left=4 top=42 right=235 bottom=512
  63. -- title width / last selected line: 0
  64. -- icon id / first selected line: 0 / 0
  65. -- text alignment: 0
  66. -- font id: 3
  67. -- text size: 9
  68. -- style flags: 0
  69. -- line height: 10
  70. -- part name: Print Options
  71.  
  72.  
  73. -- part 15 (button)
  74. -- low flags: 00
  75. -- high flags: 8000
  76. -- rect: left=400 top=275 right=326 bottom=470
  77. -- title width / last selected line: 0
  78. -- icon id / first selected line: 1007 / 1007
  79. -- text alignment: 1
  80. -- font id: 0
  81. -- text size: 12
  82. -- style flags: 0
  83. -- line height: 16
  84. -- part name: print example
  85. ----- HyperTalk script -----
  86. on mouseUp
  87.   global pagesPrinted, Version
  88.   answer "Print or just show output on the screen?" with "Cancel" OR "Print" OR "Show"
  89.   if it is "Cancel" then exit mouseUp
  90.   if it is "Show" then
  91.     put "TUN" into oKeys
  92.   else
  93.     put "TU" into oKeys
  94.   end if
  95.   put card field "print options" of card 1 into specs
  96.   go to last card -- go to the card to be printed first
  97.   put the number of cards of this bkgnd into item 1 of specs
  98.   prFlds "specs",oKeys -- the name of the specs variable must be in quotes
  99.   go to card 1
  100.   answer "Pages: " & PagesPrinted & ", Version: " & Version
  101. end mouseUp
  102.  
  103.  
  104. -- please note: This button is an example that depends on the print
  105. -- specifications being loaded in a card field named "print options"
  106. -- of the first card of the stack.  The options chosen request a title
  107. -- on each page and a line drawn between each record.  Also, the version
  108. -- number will be shown as the print process begins.  To make this
  109. -- button work on your stack, you must have your stack designed that way
  110. -- or else you will need to somehow get the print
  111. -- specifications into a variable (including the number of cards) and
  112. -- then pass that variable name as the first argument to prFlds.
  113.  
  114.  
  115. -- part 16 (field)
  116. -- low flags: 81
  117. -- high flags: 0007
  118. -- rect: left=5 top=18 right=342 bottom=510
  119. -- title width / last selected line: 0
  120. -- icon id / first selected line: 0 / 0
  121. -- text alignment: 0
  122. -- font id: 3
  123. -- text size: 9
  124. -- style flags: 0
  125. -- line height: 10
  126. -- part name: About
  127. ----- HyperTalk script -----
  128. on mouseUp
  129.   hide the target
  130. end mouseUp
  131.  
  132.  
  133. -- part 17 (field)
  134. -- low flags: 81
  135. -- high flags: 0007
  136. -- rect: left=11 top=75 right=268 bottom=512
  137. -- title width / last selected line: 0
  138. -- icon id / first selected line: 0 / 0
  139. -- text alignment: 0
  140. -- font id: 3
  141. -- text size: 9
  142. -- style flags: 0
  143. -- line height: 10
  144. -- part name: layout
  145. ----- HyperTalk script -----
  146. on mouseUp
  147.   hide the target
  148. end mouseUp
  149.  
  150.  
  151. -- part 18 (field)
  152. -- low flags: 81
  153. -- high flags: 0007
  154. -- rect: left=3 top=21 right=265 bottom=512
  155. -- title width / last selected line: 0
  156. -- icon id / first selected line: 0 / 0
  157. -- text alignment: 0
  158. -- font id: 3
  159. -- text size: 9
  160. -- style flags: 0
  161. -- line height: 10
  162. -- part name: selection
  163. ----- HyperTalk script -----
  164. on mouseUp
  165.   hide the target
  166. end mouseUp
  167.  
  168.  
  169. -- part 20 (field)
  170. -- low flags: 81
  171. -- high flags: 0004
  172. -- rect: left=119 top=33 right=242 bottom=476
  173. -- title width / last selected line: 0
  174. -- icon id / first selected line: 0 / 0
  175. -- text alignment: 0
  176. -- font id: 3
  177. -- text size: 10
  178. -- style flags: 0
  179. -- line height: 13
  180. -- part name: about build
  181. ----- HyperTalk script -----
  182. on mouseUp
  183.   hide me
  184. end mouseUp
  185.  
  186.  
  187. -- part contents for card part 12
  188. ----- text -----
  189. 1,1,14,8/30,Insurance/Income
  190. 17,14,45,294,65,New York,12,16,p,left,no,name
  191. 18,316,136,342,153,Geneva,12,16,u,left,no,Bday
  192. 19,350,136,376,153,Geneva,12,16,u,left,no,Bmonth
  193. 20,384,136,410,153,Geneva,12,16,u,left,no,Byear
  194. 21,446,136,472,153,New York,12,16,o,left,no,age
  195. 22,377,24,468,39,Geneva,9,12,be,right,no,Client ID
  196. 23,467,24,503,39,Geneva,9,12,be,left,no,suffix
  197. 24,341,47,503,64,Geneva,12,16,p,left,no,Social Security #
  198. 25,15,68,221,118,Geneva,12,16,p,left,no,Address
  199. 26,15,121,163,138,Monaco,12,16,p,left,no,Home Phone
  200. 27,214,172,362,189,Geneva,12,16,i,left,no,Work Phone
  201. 29,15,149,189,166,Geneva,12,16,p,left,no,Insurance
  202. 41,39,172,211,189,Geneva,12,16,i,left,no,Employer
  203. 43,364,172,461,189,Geneva,12,16,bi,left,no,Income
  204.  
  205. -- part contents for card part 16
  206. ----- text -----
  207. SUGGESTED USE OF THIS STACK: 
  208.  (1) Read the notes here and those shown by clicking on the button "PrFlds Parameter Layout".
  209.  (2) Copy a card, from a stack you want printed, to the end of this stack.
  210.  (3) Arrange the fields the way you want then printed on the page (location, size, font, etc.).
  211.  (4) Return to this card.  Click on the "Build Print Specs" button on this card and answer the questions.
  212.  (5) Make any embellishments to the Specs that you want (see instructions in Parameter Layout text).
  213.  (6) Click on the "print example" button.
  214.  (7) Install PrFlds XCMD into your stack, copy the specs field (with contents) and print button into your stack.
  215.  
  216. ABOUT THIS XCMD:
  217.      PrFlds is an external command (XCMD) that gives general purpose printing capabilities for the content of background fields of a stack.  This version (2.3) is limited to 100 fields (or items) per card.
  218.      PrFlds allows for specification of text areas for each background field.  These text areas may be anywhere on the printed page and of any size and the text in the area may be any one of any fonts recognized by the System, any size, style, line height and justification.  The text area may also be enclosed by a box.  Text may cover more than one page if needed.
  219.      The collection of fields printed from a card (hereafter called a Record) may also be printed in columns on the page.  For example, the definitions of the text areas for a record may fit within a space 3.5 inches wide by 3.5 inches high (thus printing in two columns with  three records per column).  The text printed may be the contents of a background field, any other text, or even the evaluation of a HyperTalk expression (e.g. the long date).  The pages of the report produced by PrFlds may also have a title line, including page numbers.
  220.      Selection criteria can be specified, in the form of a HyperTalk function handler and located in the stack or background script.  With this option, a certain subset of the cards of the background may be printed.
  221. Click on the button "PrFlds Parameter Layout" for a description of the calling methods of PrFlds.
  222.  
  223. Changes in PrFlds to make version 1.9: a MAJOR bug fix (a problem if more objects were specified than the number of bkgnd fields).  Also better error recovery, i.e. if something goes wrong, it should return properly.
  224.  
  225. Changes in PrFlds to make version 2.0: the capability was added to define "bottomless" fields, i.e. you can have a field print for the length of its contents, even over a page boundary.  See the definition of items 4 and 5 of the objects line definitions in the "PrFlds Parameter Layout" for a description.  ALSO - if you use the "preview" option, you now get a message in the lower right corner instead of the middle of the screen.  The "Quick" option was added to allow printing without the annoying dialog box.  The change between 2.0b4 and 2.0b5 fixed a bug on the validation of the print record.  Also fixed was a bug where Chicago font was being changed to Geneva.  A final fix (really?!) was made to PrFlds so that if HyperCard switched graph ports during the process, PrFlds switched back.  This fixes a problem that usually only shows up on the AppleTalk Imagewriter where parts of pages do not print.
  226.  
  227. Other Changes:  PrFlds now recognizes the ASCII formfeed character (Hex 0C) and starts the following text on the next page.  A top margin can now be specified separate from the record spacing gap.
  228.  
  229. PRFlds is Copyright ┬⌐ 1990, University of Utah Computer Center (MEB 3440), Salt Lake City, Utah  84112
  230.  
  231. PrFlds was written by Joseph F. Buchanan at the University of Utah Computer Center and is available for use by anyone provided that proper credit is given for it and its use is not for profit.  Inquiries and questions may be directed to me at the University of Utah Computer Center at (801) 581-6802 or AppleLink: A91, or bitnet: Joseph@UUCC.Utah.edu  .
  232.  
  233.  
  234. -- part contents for card part 17
  235. ----- text -----
  236. How to call PrFlds
  237.  
  238. PrFlds is VERY general purpose and is therefore rather detailed in its specifications.  Most of the specifications need to be loaded into a variable (container) and the name of the variable is then passed as the first parameter to the XCMD.  The second parameter specifies options and the third parameter (if needed) contains the name of a handler (hyperTalk function handler found in the background or stack script).  LIMITS: This version of PrFlds (2.3) is limited to 100 objects per record (card) in the report.
  239.  
  240. As PrFlds returns, you can find two pieces of information stored in global variables:
  241.      PagesPrinted - the actual number of pages that were printed by PrFlds
  242.      Version - the current version number of PrFlds, in the form: nn.n mm/dd/yy  (this is also shown on
  243.             the screen if you specify the "V" option as shown below).
  244.  
  245. The options available to PrFlds are as follows:
  246. ΓÇóN - Do not send output to the printer.  Instead, show the output on the screen.  This will show a test page.
  247. ΓÇóB - Process cards only of this background (of the card showing when PrFlds is invoked).
  248.  Note: if all cards are processed and different backgrounds are encountered where ANY of the specified fields do not exist for that particular background, an error will occur and the print process will fail.
  249. ΓÇóL - Lock the screen - do not show each card as it is processed.  This speeds things up a bit.
  250. ΓÇóP - Do a Page Setup dialog.  This is useful for specifying page orientation and size.
  251. ΓÇóQ - Quick printing - really, this means that the normal print dialog is bypassed.
  252. ΓÇóS - Look for selection criterea in a HyperTalk function (the name of which is in the third parameter).
  253. ΓÇóT - print the title (see line 1, item 5) on each page (also the page number)
  254. ΓÇóU - Underline, i.e. draw a line on the page after each record (all fields printed for each card).
  255. ΓÇóV - Show the version of PrFlds.  This will appear in a dialog box before printing begins.
  256.  
  257. Example:
  258.                   prFlds "specs","BSUP","ChooseCard(23)"
  259.  
  260. and the "ChooseCard" hyperTalk function handler returning TRUE or FALSE.  This feature is described in detail if you click on the "Special Selection Function" button below.
  261.  
  262. The example shown will display a Page Setup dialog before printing.  When printing, it will select only those cards of the background satisfy the condition specified in the function ChooseCard.  A line will be drawn after each record.
  263.  
  264. The "Specs" information is as follows:
  265.  
  266. ΓÇó line 1:
  267.    ΓÇó item 1: The number of cards to be printed (or examined).  This is usually the number of cards of the
  268.                   background or stack.  If, instead, you desire to print multiple copies if one record (the
  269.                   contents of the current card), then precede this number by the letter "R".
  270.    ΓÇó item 2: The number of columns per page.  The ENTIRE page layout makes up a column here, not
  271.                   individual fields.
  272.                   NOTE -  Column boundaries are calculated by dividing the
  273.                   number of columns into the page width.  If the size and location parameters of individual fields
  274.                   exceed these boundaries, those areas of the printed page will be overwritten.
  275.    ΓÇó item 3: The number of objects to be printed in the record.  This includes each field as well as other
  276.                   information that is specified in the subsequent lines of this "Specs" information area.  This is 
  277.                   usually the number of lines of "Specs" minus 1.
  278.    ΓÇó item 4: The size of the gap showing between records (and at the top of the page). If this number is
  279.                   followed by a slash (/) and another number, that number specifies the top of page margin.
  280.    ΓÇó item 5: The title to show at the top of each page.  If there is something in this item, even if it is a
  281.                   space character, then a title will be printed, along with a page number, otherwise no title nor
  282.                   page numbers will be printed.
  283.  
  284. ΓÇó all other lines (one line per object or field):
  285.    ΓÇó item 1: Object identification - one of the following:
  286.                 a.  The background field ID number (a positive number).
  287.                       OR
  288.                 b.  The negative value of a background field ID number - The name of the background field is to
  289.                      be printed instead of its value.
  290.                       OR
  291.                 c.  The letter "X" - in this case the text found in item 12 will be evaluated as a HyperTalk
  292.                      expression and used in this place.
  293.                       OR
  294.                 d.   The number "0" - The text in item 12 is to be printed as is.
  295.  
  296.            NOTE:  If item 12 is blank for choices c or d above, then no text will be printed, rather, a line will
  297.              be drawn connecting the points specified in items 2 and 3 with those in items 4 and 5.
  298.    ΓÇó items 2 and 3:  The coordinates of the left top corner of the rectangle to contain the text specified in
  299.        item 1.
  300.    ΓÇó items 4 and 5:  The coordinates of the right bottom corner of the rectangle to contain the text
  301.        specified in item 1.  If you want the field to conform to the actual needs of the text, then precede
  302.        item 5 with an asterisk (e.g. *175).  This will also allow the field to expand, going onto a subsequent
  303.        page if necessary.  Please be aware that with this option, no other fields should be placed below this
  304.        rectangle, because they may be overwritten.  If this feature is used, then page counting estimates
  305.        may be unreliable.  The text rectangle bottom specified will be honored and the minimum length will
  306.        be used, even if that much space is not needed, but more will be used if needed.  You can only have
  307.        10 fields go over a page boundary at a time, but that shouldn't be a problem.
  308.       NOTE: The coordinates are specified in the same manner as that of the Macintosh screen, i.e. the top
  309.          left corner of the screen is 0,0 and the bottom right is 512,342.  Paper sizes are appropriately
  310.          larger with the size being approximately 75 dots per inch.  PrFlds DOES NOT check to see if page
  311.          boundaries are exceeded.  If you specify areas beyond the physical page, the specified text will not
  312.          show.  Also, note that if a box os to be drawn around a text object, it will appear a few pixels
  313.          beyond the specified rectangle and can therefore be drawn off the edge of the page.
  314.       ALSO:  As explained in item 1, a line may be drawn from the point defined by items
  315.          2 and 3 to the point defined by items 4 and 5.
  316.    ΓÇó item 6:  The Font name.  This can be any font name as recognized by the System.
  317.    ΓÇó item 7:  The Font size.
  318.    ΓÇó item 8:  The text height (the height of the line).
  319.    ΓÇó item 9:  The text style.  Use the first letter of the style.  Combine as many as you like.  These can
  320.                       include: Plain, Bold, Italic, Underline, Outline, Shadow, Extend, Compress.
  321.    ΓÇó item 10: The text alignment:  Center, Left or Right.
  322.    ΓÇó item 11:  Border?  If yes, then a border is drawn around the text box, otherwise not.  If you enter a 
  323.                     "G" here, PrFlds will try to make a gray box in the area of the rectangle.  This works for 
  324.                     the LaserWriter.
  325.    ΓÇó item 12:  A text description.  This is treated as a comment and ignored unless item 1 is "0" or "X".
  326.  
  327. A button has been programmed on this card to take a card of background fields and construct a print specifications list based on those background fields.  You can copy a card from your stack and paste it into this stack and then use the button to see how to construct the print specifications.  You may not want the same arrangement of fields in your printed report as is on your card, so you might first re-adjust the location of your fields and eliminate some fields from the constructed list.  You may also wish to embellish the record with other objects like field names, additional information and borders.
  328.  
  329. Note: The physical size on the paper of the area to contain the record objects is determined by the rectangles specified for the record objects.  The highest number of the item 4 parameters of the objects list is used as the height of the record rectangle.  The height of the record plus the record gap will be used to determine how many records can fit on a page.  The exception to this is when an object definition has an asterisk preceding the item 4 number, then the object print area will expand down as far as is needed.  IF A FIELD IS CONTINUED TO ADDITIONAL PAGES, then the top of itsrectangle is set to the top of the page.  Be sure to not have more than one continuing field in the same vertical space or else they will be overwritten.
  330.  
  331. AND.. as of version 2.2, PrFlds will recognize the ASCII FormFeed character (0C in hex, 12 in decimal), and will break the print at that point and continue it on the next print area (next page is assumed, but if more than 1 print area fits on a page, so will the continuations).  The only problem with FormFeed characters, is that Hypercard insists on removing control characters from fields.  You can embed the character by using NumToChar(12) into your fields.
  332.  
  333. PrFlds will put out the number of pages actually printed.  You will find this number in the global variable: PagesPrinted.  If you specify a page range, PrFlds will go through the motions of printing any previous pages (taking some time) then it will begin work on the specified pages.  Depending on the size needed for expandable fields, this page count may not be correct.
  334.  
  335. Other Notes:
  336.      As PrFlds works, it examines all cards, the cards will appear on the screen as they are considered.
  337.      As the report is being printed, a status is shown in the message window showing the approximate progress (by page number being processed and percent of cards of the stack).  This progress is only an approximate and may not be totally accurate.
  338.      Printing will not actually begin until the entire report is processed.  Then if the print does not happen, it may be that there was not enough room on the system disk or in memory to assemble the report (or else that disk was locked).
  339.  
  340. -- part contents for card part 18
  341. ----- text -----
  342. In printing your information from a stack, you may want to extract a subset from the total collection of cards of the background.  The third parameter to the PrFlds XCMD will be used to make the determination whether a particular card is to be printed.
  343.  
  344. The following is the method loop of card examination:
  345.  
  346. ΓÇó a. If the S option is specified, then evaluate the function whose name is found in the third parameter.
  347.     - if the returned value of the function is FALSE, then ignore the card
  348.    b.  if the S option is not specified, OR if the value returned is TRUE, then process the card.
  349. ΓÇó Go to the next card of this background.
  350.  
  351. The function will usually be a hyperTalk function handler that you put in the background or stack script, but it might also be something else that returns TRUE or FALSE.
  352.  
  353. An example is as follows:
  354.  
  355.                   prFlds "specs","S","ChooseCard(23)"
  356.  
  357.   function ChooseCard xxx
  358.     if field age>xxx then
  359.       return TRUE
  360.     else
  361.       return FALSE
  362.     end if
  363.   end ChooseCard
  364.  
  365. The card will be chosen if it has a value in the background field AGE of greater than 23.
  366.  
  367. ADDITIONAL INFORMATION:
  368.  
  369. In most cases, a Control-period will terminate the process of printing.  Sometimes the XCMD might be in your function at the time of some loop problem.  Therefore PrFlds was designed to also look for a "Cancel" to be returned from the function and then cancel the entire print process.  A use of this is shown below:
  370.  
  371.   function ChooseCard xxx
  372.     if the commandKey is down then  -- Note: we cannot check for a period, only the commandKey
  373.       return "Cancel"
  374.       exit ChooseCard
  375.     end if
  376.     if field age>xxx then
  377.       return TRUE
  378.     else
  379.       return FALSE
  380.     end if
  381.   end ChooseCard
  382.  
  383. In this example, if you hold the command key down while the selection function is invoked, the "Cancel" message will be returned to PrFlds and the process will terminate.
  384.  
  385.  
  386. -- part contents for card part 19
  387. ----- text -----
  388. 2.3.1
  389.  
  390. -- part contents for card part 20
  391. ----- text -----
  392. The "Build Print Specs" button is supplied to give you a method for creating the printing specifications graphically.  You should copy a card from your stack into this stack and re-arrange the fields and set their display attributes (font/size/style, etc.) to the way you might want them printed.  Then click on the "Build" button and specify the card number.  The button will then construct a field containing the printing specifications.  You can then look at them and make adjustments as necessary.  Unfortunately, this method is not very good for laying out onto complete pages (because of Hypercard's screen limitations), but you can at least get a good idea of how to lay out the fields.  When you are ready to set up your stack for printing,  you will need to store your print specifications in a field or script in your stack so that you can load a variable and send it to PrFlds to have it do the printing.  See the script of the "Print example" button to see how this could be done.